<template>
  <div>
    <el-form-item label="图标">
      <icon-picker v-model="localData.iconName" />
    </el-form-item>
    <el-form-item label="尺寸">
      <el-input-number v-model="localData.iconSize" controls-position="right" />
    </el-form-item>
    <el-form-item label="颜色">
      <el-color-picker v-model="localData.iconColor" />
    </el-form-item>
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import { IconPicker } from '@/components/IconPicker';

export default defineComponent({
  name: 'AnvilIconConfig',
  components: { IconPicker },
  props: {
    data: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      localData: {}
    };
  },
  watch: {
    data: {
      handler(newVal) {
        if (newVal) {
          this.localData = newVal;
        }
      },
      deep: true,
      immediate: true
    },
    localData: {
      handler(newVal) {
        this.$emit('update:data', newVal);
      },
      deep: true
    }
  }
});
</script>
